package com.bestvike.stone.spring.mail;

import com.bestvike.stone.spring.mail.core.Mail;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

/**
 * Created by 许崇雷 on 2017-11-20.
 */
@CommonsLog
@Component
@ConditionalOnClass(JavaMailSender.class)
public final class MailUtils {
    private static MailTemplate mailTemplate;

    MailUtils(MailTemplate mailTemplateInstance) {
        mailTemplate = mailTemplateInstance;
    }

    public static void send(Mail mail) {
        mailTemplate.send(mail);
    }

    public static void sendAsync(Mail mail) {
        mailTemplate.sendAsync(mail);
    }
}
